#include "app_at24c02.h"

#include "bsp_at24c02.h"
#include "app_debug_printf.h"

at24c02_content_t at24c02_content = {0};

uint8_t at24c02_update_content(void)
{
	return at24c02_wr(0, (uint8_t *)&at24c02_content, sizeof(at24c02_content));
}

uint8_t at24c02_get_content(void)
{
	return at24c02_rd(0, (uint8_t *)&at24c02_content, sizeof(at24c02_content));
}

void at24c02_test(void)
{
	uint8_t buf[256] = {0};

	for (uint16_t i = 0; i < sizeof(buf); ++i)
	{
		buf[i] = 99;
	}

	if (!at24c02_wr(0, buf, sizeof(buf)))
	{
		debug_printf("at24c02_wr error\r\n");
	}

	for (uint16_t i = 0; i < sizeof(buf); ++i)
	{
		buf[i] = 0;
	}

	if (!at24c02_rd(0, buf, sizeof(buf)))
	{
		debug_printf("at24c02_rd error\r\n");
	}

	debug_printf("data from at24c02_buf:\r\n");
	for (uint16_t i = 0; i < 256; ++i)
	{
		debug_printf("%d ", buf[i]);
	}
	debug_printf("\r\n");
}
